package com.zzyl.nursing.controller;

import java.util.List;
import com.zzyl.nursing.dto.CancelInfoDto;
import com.zzyl.nursing.dto.ExecuteTaskDto;
import com.zzyl.nursing.dto.TaskUpdateTimeDto;
import com.zzyl.nursing.vo.NursingTaskVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.service.INursingTaskService;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 护理任务Controller
 * 
 * @author fhy
 * @date 2025-10-23
 */
@RestController
@RequestMapping("/nursing/nursingTask")
@Api(tags = "护理任务的接口")
public class NursingTaskController extends BaseController
{
    @Autowired
    private INursingTaskService nursingTaskService;

    /**
     * 查询护理任务列表
     * controller层
     */
    @ApiOperation("查询护理任务列表")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(NursingTask nursingTask)
    {
        startPage();
        List<NursingTask> list = nursingTaskService.selectNursingTaskList(nursingTask);
        return getDataTable(list);
    }
    /**
     * 取消护理任务
     * controller层
     */
    @ApiOperation("取消护理任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:edit')")
    @PutMapping("/cancel")
    public AjaxResult cancel(@RequestBody CancelInfoDto cancelInfoDto) {
        nursingTaskService.updateNursingTask(cancelInfoDto);
        return AjaxResult.success();
    }
    /**
     * 执行护理任务
     * controller层
     */
    @ApiOperation("执行护理任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:doit')")
    @PutMapping("/do")
    public AjaxResult donNrsingTask(@RequestBody ExecuteTaskDto dto) {
        nursingTaskService.donNrsingTask(dto);
        return AjaxResult.success();
    }
    /**
     * 任务改期
     * controller层
     */
    @ApiOperation("更期护理任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:update')")
    @PutMapping("/updateTime")
    public AjaxResult updateTime(@RequestBody TaskUpdateTimeDto dto) {
        nursingTaskService.updateTime(dto);
        return AjaxResult.success();
    }


    /**
     * 获取护理任务详细信息
     * controller层
     */
    @ApiOperation("获取护理任务详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        NursingTaskVo vo = nursingTaskService.selectNursingTaskById(id);
        return AjaxResult.success(vo);
    }
}